# -*- coding: utf-8 -*-
# @Author : HaleShi
# @Time : 2023-07-04
# @File : 2_login.py

import requests
import uuid


def login_by_pwd(mobile, password, app_key, device_identify):
    res = requests.post(
        url="https://newappuser.jiuxian.com/user/loginUserNamePassWd.htm",
        data={
            "appKey": app_key,
            "appVersion": "9.0.30",
            "areaId": "500",
            "channelCode": "0",
            "cpsId": "xiaomi",
            "deviceIdentify": device_identify,
            "deviceType": "ANDROID",
            "deviceTypeExtra": "0",
            "equipmentType": "Pixel 2 XL",
            "netEnv": "wifi",
            "passWord": password,
            "screenReslolution": "1440x2712",
            "supportWebp": "1",
            "sysVersion": "10",
            "userName": mobile
        },
        headers={
            "Content-Type": "application/x-www-form-urlencoded",
            "secure": "false",
        }
    )
    data_dict = res.json()
    print(data_dict)

    token = data_dict['result']['userInfo']['token']
    return token


def run():
    app_key = device_identify = str(uuid.uuid4())
    # app_key = device_identify = ""
    mobile = "18378353331"
    password = str(input("请输入密码:\n"))

    token = login_by_pwd(mobile, password, app_key, device_identify)

    print(token)


if __name__ == '__main__':
    run()
